<!DOCTYPE html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <title>密码复杂度测试Demo</title>

    <!--    <script src="https://sec.unicompayment.com/wpc/js/password-check-1.0.0/password.check.min.js" type="text/javascript"></script>-->
    <script src="https://fptest.unicompayment.com:8000/wpc/js/password-check-1.0.0/password.check.js"
            type="text/javascript"></script>
    <script src="https://fptest.unicompayment.com:8000/wpc/js/password-check-1.0.0/password.check.min.js"
            type="text/javascript"></script>
    <script type="text/javascript">
        // function checkValue() {
        //     var user = document.getElementById("userName");
        //     var password = document.getElementById("passWord");
        //     var result = new EpayPasswordCheck().check(password, user);
        //     document.getElementById("result").innerHTML(result ? "通过" : "不通过");
        // }
        // <script type="text/javascript">
        function checkValue() {
            var username = document.getElementById("userName").value;
            var password = document.getElementById("passWord").value;
            // var result = new EpayPasswordCheck().check(password, username);

            //  var result = new EpayPasswordCheck({"returnErrorMsg": true}).check(password，username);
            //但密码也可以验证
            var result = new EpayPasswordCheck({"returnErrorMsg": true}).check(password,username);
            //result = {result: false, msg: "验证不通过！密码长度不能小于[8]，
            // 并且不能大于[24]"}, password = "123456", username = "admin"

            //   document.getElementById("result").innerHTML = (result ? "不通过" : "通过");
            //s1 = "{\"result\":false,\"msg\":\"验证不通过！密码长度不能小于[8]，并且不能大于[24]\"}", result = {result: false, msg: "验证不通过！密码长度不能小于[8]，并且
            var s1 = JSON.stringify(result);
            //obj = {result: false, msg: "验证不通过！密码长度不能小于[8]，并且不能大于[24]"}
            var obj = new Function("return" + s1)();
            alert(obj.result);//json name    false
            alert(obj.msg);//验证不通过！密码长度不能小于[8]，并且不能大于[24]
            console.log(obj);
            console.log(obj.msg, obj.result);
            //s = "<a name=\"[object Object]\"></a>", result = {result: false, msg: "验证不通过！密码长度不能小于[8]，
            // 并且不能大于[24]"}
            var s = document.getElementById("result").innerHTML.anchor(result);
            console.log(s, s1);
        }
    </script>
</head>
<body>
<input id="userName" value="admin"></input>
<input id="passWord" value="123456"></input>
<button onclick="checkValue()">测试按钮</button>
<div id="result"></div>
</body>
</html>

